package test

import config.MyFile
import org.apache.commons.io.FileUtils

import scala.io.Source
import scala.jdk.CollectionConverters._

object GetBlastData extends MyFile {

  def main(args: Array[String]): Unit = {

    "I:\\hordeum_db\\fasta\\genome".listFile.filter(_.getName.endsWith("genome")).foreach { x =>
      val name = x.getName.split('.').head
      Source.fromFile(x).getLines().grouped(100000).foreach { x =>
        val row = x.map{y=>
          if(y.startsWith(">")){
            y.split(" ").head + "-" + name
          }else{
            y
          }
        }
        FileUtils.writeLines("I:\\hordeum_db/blastData/genome/genome.fa".toFile, row.toBuffer.asJava, true)
      }

    }
  }
}
